<template>
  <div class="unit_payment">
    <div class="header_title">
      <span>单位支付参数</span>
    </div>
    <div class="list">
      <el-form
        ref="alldata"
        :model="alldata"
        :rules="alldatarule"
        :label-position="labelPosition"
        label-width="150px"
        class="clearfix"
      >
        <!-- <el-col :span="12">
          <el-form-item label="支付宝pid:" prop="unitPid">
            <el-col :span="8">
              <el-input v-model="alldata.unitPid" size="mini"></el-input>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="支付宝编号:" prop="unitNo">
            <el-col :span="8">
              <el-input v-model="alldata.unitNo" size="mini"></el-input>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="省份编号:" prop="provinceCode">
            <el-col :span="8">
              <el-input v-model="alldata.provinceCode" size="mini"></el-input>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="城市编号:" prop="cityCode">
            <el-col :span="8">
              <el-input v-model="alldata.cityCode" size="mini"></el-input>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="县区编号:" prop="districtCode">
            <el-col :span="8">
              <el-input v-model="alldata.districtCode" size="mini"></el-input>
            </el-col>
          </el-form-item>
        </el-col>-->

        <!-- <el-col :span="12">
          <el-form-item label="微信商户id:" prop="vxMchId">
            <el-col :span="8">
              <el-input
                v-model="alldata.vxMchId"
                size="mini"
                :disabled="!alldata.payChannelList.includes('微信支付')"
                :maxlength="10"
              ></el-input>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="支付宝商户id:" prop="sellerId">
            <el-col :span="8">
              <el-input
                v-model="alldata.sellerId"
                size="mini"
                :disabled="!alldata.payChannelList.includes('支付宝')"
              ></el-input>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="支付宝商户凭证:" prop="authToken">
            <el-col :span="8">
              <el-input
                v-model="alldata.authToken"
                size="mini"
                :disabled="!alldata.payChannelList.includes('支付宝')"
              ></el-input>
            </el-col>
          </el-form-item>
        </el-col>-->
        <el-col :span="24">
          <el-form-item label="支付渠道:" prop="paymentChannel">
            <el-checkbox-group v-model="alldata.payChannelList">
              <el-checkbox label="支付宝沙箱"></el-checkbox>
              <el-checkbox label="支付宝"></el-checkbox>
              <el-checkbox label="杭州教育"></el-checkbox>
              <el-checkbox label="微信支付"></el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="充值最小金额:" prop="rechargeAmountMin">
            <el-col :span="10">
              <el-input v-model="alldata.rechargeAmountMin" size="mini"></el-input>
            </el-col>
            <span :style="{ paddingLeft: '10px' }">元</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="充值最大金额:" prop="rechargeAmountMax">
            <el-col :span="10">
              <el-input v-model="alldata.rechargeAmountMax" size="mini"></el-input>
            </el-col>
            <span :style="{ paddingLeft: '10px' }">元</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="是否可以自定义充值:">
            <el-col :span="4">
              <el-switch
                v-model="alldata.isCustomAmount"
                active-text="是"
                inactive-text="否"
                :active-value="1"
                :inactive-value="0"
              ></el-switch>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="用户手续费:" prop="rate">
            <el-col :span="10">
              <el-input v-model="alldata.rate" size="mini"></el-input>
            </el-col>
            <!-- <el-col :span="2" style="margin-left:20px"> -->
            <span :style="{ paddingLeft: '10px' }">%</span>
            <!-- </el-col> -->
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="平台钱包:" prop="platformWalletNo">
            <el-col :span="10">
              <el-select v-model="alldata.platformWalletNo" placeholder="请选择" size="mini" clearable>
                <el-option
                  v-for="item in platformWalletlist"
                  :key="item.walletNo"
                  :label="item.walletName"
                  :value="item.walletNo"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="消费钱包:" prop="consumeWalletNo">
            <el-col :span="10">
              <el-select
                v-model="alldata.consumeWalletNo"
                placeholder="请选择"
                size="mini"
                clearable
                :disabled="iswalletModel"
              >
                <el-option
                  v-for="item in paylist"
                  :key="item.walletNo"
                  :label="item.walletName"
                  :value="item.walletNo"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="缴费钱包:" prop="paymentWalletNo">
            <el-col :span="10">
              <el-select v-model="alldata.paymentWalletNo" placeholder="请选择" size="mini" clearable>
                <el-option
                  v-for="item in platformWalletlist"
                  :key="item.walletNo"
                  :label="item.walletName"
                  :value="item.walletNo"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="公话钱包:" prop="voipWalletNo">
            <el-col :span="10">
              <el-select v-model="alldata.voipWalletNo" placeholder="请选择" size="mini" clearable>
                <el-option
                  v-for="item in voipWalletlist"
                  :key="item.walletNo"
                  :label="item.walletName"
                  :value="item.walletNo"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="水控钱包:" prop="waterWalletNo">
            <el-col :span="10">
              <el-select
                v-model="alldata.waterWalletNo"
                placeholder="请选择"
                size="mini"
                clearable
                :disabled="iswalletModel"
              >
                <el-option
                  v-for="item in paylist"
                  :key="item.walletNo"
                  :label="item.walletName"
                  :value="item.walletNo"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="电控钱包:" prop="electricWalletNo">
            <el-col :span="10">
              <el-select
                v-model="alldata.electricWalletNo"
                placeholder="请选择"
                size="mini"
                clearable
                :disabled="iswalletModel"
              >
                <el-option
                  v-for="item in paylist"
                  :key="item.walletNo"
                  :label="item.walletName"
                  :value="item.walletNo"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="电吹风钱包:" prop="hairWalletNo">
            <el-col :span="10">
              <el-select
                v-model="alldata.hairWalletNo"
                placeholder="请选择"
                size="mini"
                clearable
                :disabled="iswalletModel"
              >
                <el-option
                  v-for="item in paylist"
                  :key="item.walletNo"
                  :label="item.walletName"
                  :value="item.walletNo"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="发卡机发卡钱包:" prop="issuingWalletNo">
            <el-col :span="10">
              <el-select
                v-model="alldata.issuingWalletNo"
                placeholder="请选择"
                size="mini"
                clearable
                :disabled="iswalletModel"
              >
                <el-option
                  v-for="item in paylist"
                  :key="item.walletNo"
                  :label="item.walletName"
                  :value="item.walletNo"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item>
            <el-button type="primary" @click="onSubmit()">保存信息</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </div>
    <div class="fanshionable_title">
      <span>分账列表</span>
    </div>
    <div class="fanshionable_list">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item>
          <el-button type="primary" @click="addfanshionable" size="mini" icon="el-icon-plus">新增</el-button>
        </el-form-item>
      </el-form>
      <el-table
        v-loading="dataListLoading"
        :data="fanshionabledata"
        border
        highlight-current-row
        style="width: calc(100%)"
        :cell-style="(res) => headFirst_col(res, [])"
      >
        <el-table-column prop="loginName" label="支付宝账号"></el-table-column>
        <el-table-column prop="userName" label="用户名"></el-table-column>
        <el-table-column prop="percentage" label="分帐比例%"></el-table-column>
        <el-table-column prop="settleType" label="分帐说明"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button type="text" size="mini" @click="addOrUpdateHandle(scope.row)">修改</el-button>
            <el-button
              type="text"
              size="mini"
              style="color: red"
              @click="deleOrUpdateHandle(scope.row)"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="page">
        <el-pagination
          @size-change="handleSizeChange1"
          @current-change="handleCurrentChangepage1"
          :current-page="currentPage1"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageSize1"
          layout="total, sizes, prev, pager, next, jumper"
          :total="recordCount1"
        ></el-pagination>
      </div>
      <!-- 修改账户列表 -->
      <el-dialog
        width="500px"
        center
        title="修改分账列表"
        :before-close="editcloseDialog"
        :close-on-click-modal="false"
        :visible.sync="editFormVisible"
      >
        <el-form
          :model="editForm"
          :rules="editdataRule"
          ref="editForm"
          @keyup.enter.native="editFormSubmit()"
          label-width="80px"
        >
          <el-form-item label="分账比例" prop="percentage">
            <el-col :span="15">
              <el-input v-model="editForm.percentage" placeholder="分账比例" size="mini"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="分帐说明" prop="settleType">
            <el-col :span="15">
              <el-input v-model="editForm.settleType" placeholder="分帐说明" size="mini"></el-input>
            </el-col>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="editvisible()">取消</el-button>
          <el-button type="primary" @click="editataFormSubmit()">确定</el-button>
        </span>
      </el-dialog>
      <!-- 新增账户列表 -->
      <el-dialog
        width="500px"
        center
        title="新增分账账户"
        :before-close="addcloseDialog"
        :close-on-click-modal="false"
        :visible.sync="addFormVisible"
      >
        <el-form
          :model="addForm"
          :rules="adddataRule"
          ref="addForm"
          @keyup.enter.native="addFormSubmit()"
          label-width="100px"
        >
          <el-form-item label="支付宝账号" prop="agentAccount">
            <el-col :span="15">
              <el-input v-model="addForm.agentAccount" placeholder="支付宝登录账号" size="mini"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="用户名" prop="agentName">
            <el-col :span="15">
              <el-input v-model="addForm.agentName" placeholder="支付宝实名制名称" size="mini"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="分账比例" prop="percentage">
            <el-col :span="15">
              <el-input v-model="addForm.percentage" placeholder="分账比例" size="mini"></el-input>
            </el-col>
            <span>%</span>
          </el-form-item>
          <el-form-item label="分帐说明" prop="settleType">
            <el-col :span="15">
              <el-input v-model="addForm.settleType" placeholder="分帐说明" size="mini"></el-input>
            </el-col>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="addvisible()">取消</el-button>
          <el-button type="primary" @click="addataFormSubmit()">确定</el-button>
        </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    let checkrate = (rule, value, callback) => {
      // /^(0|[1-9]\d*)(\.\d*)?$/
      let reateReg = /^(0|[1-9][0-9]*)([\.][0-9]\d*)?$/
      if (!reateReg.test(value)) {
        callback(new Error('请输入正确的费率格式！'))
      } else {
        callback()
      }
    }
    let checkpercentage = (rule, value, callback) => {
      let percentageReg = /^(0|[1-9][0-9]*)([\.][0-9]\d*)?$/
      if (!percentageReg.test(value)) {
        callback(new Error('请输入正确的分账比例格式！'))
      } else {
        callback()
      }
    }
    let checkreate = (rule, value, callback) => {
      let reateReg = /^(0|[1-9]\d*)(\.\d{0,2})?$/
      if (!reateReg.test(value)) {
        callback(new Error('请输入正确的用户手续费！'))
      } else {
        callback()
      }
    }
    let checknum = (rule, value, callback) => {
      let numReg = /^([0]|[1-9][0-9]*)$/
      if (!numReg.test(value)) {
        callback(new Error('请输入整数金额'))
      } else {
        callback()
      }
    }
    return {
      // 判断是否单钱包
      iswalletModel: false,
      labelPosition: 'right',
      formInline: {},
      pageNum1: 1,
      pageSize1: 5,
      currentPage1: 1,
      recordCount1: 0,
      fanshionabledata: [],
      dataListLoading: false,
      editFormVisible: false,
      addFormVisible: false,
      addForm: {
        percentage: '',
        settleType: '',
        agentAccount: '',
        agentName: ''
      },
      editForm: {
        percentage: '',
        settleType: ''
      },
      editdataRule: {
        settleType: [
          { required: true, message: '分账说明不能为空', trigger: 'blur' }
        ],
        percentage: [
          { required: true, validator: checkpercentage, trigger: 'blur' }
        ]
      },
      adddataRule: {
        settleType: [
          { required: true, message: '分账说明不能为空', trigger: 'blur' }
        ],
        percentage: [
          { required: true, validator: checkpercentage, trigger: 'blur' }
        ],
        agentAccount: [
          { required: true, message: '支付宝账户不能为空', trigger: 'blur' }
        ],
        agentName: [
          { required: true, message: '用户名不能为空', trigger: 'blur' }
        ]
      },
      alldata: {
        //商家token
        authToken: '',
        //城市编码
        cityCode: '',
        //县区编码
        districtCode: '',
        //主键
        pkAlipayConfigId: '',
        //省份编码
        provinceCode: '',
        //费率
        rate: '',
        // 商家id
        sellerId: '',
        //单位id
        unitGuid: '',
        //支付宝学校内编号
        unitNo: '',
        //学校类型
        unitType: '',
        //支付宝pid
        unitPid: '',
        // 微信appid
        vxMchId: '',
        //平台手续费
        platformRate: '',
        //支付渠道
        paymentChannel: '',
        payChannelList: [],
        //代理商支付宝登录名
        agentAccount: '',
        //代理商真实姓名
        agentName: '',
        // 是否可以自定义金额
        isCustomAmount: 0,
        //充值最小金额
        rechargeAmountMin: '',
        //充值最大金额
        rechargeAmountMax: '',
        // 水控钱包号
        waterWalletNo: '',
        // 电控钱包号
        electricWalletNo: '',
        // 平台钱包号
        platformWalletNo: '',
        // 缴费钱包号
        paymentWalletNo: '',
        // 电吹风钱包号
        hairWalletNo: '',
        /**
         * 发卡机发卡钱包
         */
        issuingWalletNo: '',
        /**
         * 消费钱包
         */
        consumeWalletNo: '',
        /**
         * 公话钱包
         */
        voipWalletNo: ''
      },
      // 钱包列表选项
      paylist: [],
      // 平台钱包选项
      platformWalletlist: [],
      // 公话钱包选项
      voipWalletlist: [],
      userGuid: '',
      alldatarule: {
        rate: [{ required: true, validator: checkreate, trigger: 'blur' }],
        platformRate: [
          { required: true, validator: checkrate, trigger: 'blur' }
        ],
        rechargeAmountMin: [
          { required: true, validator: checknum, trigger: 'blur' }
        ],
        rechargeAmountMax: [
          { required: true, validator: checknum, trigger: 'blur' }
        ]
      }
    }
  },
  created() {
    this.userGuid = sessionStorage.getItem('administrator')
  },
  computed: {
    changeschoolid: {
      get() {
        return this.$store.state.user.changeschoolid
      }
    }
  },
  mounted() {
    this.getPayNumber()
    this.getpayrateuser()
    this.fanshionable()
    this.getunitconfiguration()
  },
  methods: {
    //单位配置信息
    getunitconfiguration() {
      this.$http({
        url: this.$http.adornUrl('/manager/unit-config'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            unitGuid: this.changeschoolid,
            userGuid: this.userGuid
          },
          messageType: this.messageType
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          if (data.messageContent.walletModel != 2) {
            this.iswalletModel = true
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },

    // 获取钱包
    getPayNumber() {
      this.paylist = []
      this.platformWalletlist = []
      this.voipWalletlist = []
      this.$http({
        url: this.$http.adornUrl('/unit/unit-wallet-info-list'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            unitGuid: this.changeschoolid
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          data.messageContent.map(item => {
            let walletType = item.walletType
            // 所有的钱包
            this.voipWalletlist.push(item)
            if (walletType != 1) {
              this.paylist.push(item)
            } else {
              this.platformWalletlist.push(item)
            }
          })
        } else {
          this.$message({
            showClose: true,
            message: data.errorMessage,
            type: 'error'
          })
        }
      })
    },
    //获取支付信息配置
    getpayrateuser() {
      this.$http({
        url: this.$http.adornUrl('/manager/unit-alipay-config'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            unitGuid: this.changeschoolid,
            userGuid: this.userGuid
          },
          messageType: this.messageType
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          if (data.messageContent) {
            this.alldata = { ...data.messageContent }
            this.alldata.authToken = data.messageContent.authToken
            this.alldata.cityCode = data.messageContent.cityCode
            this.alldata.districtCode = data.messageContent.districtCode
            this.alldata.pkAlipayConfigId = data.messageContent.pkAlipayConfigId
            this.alldata.provinceCode = data.messageContent.provinceCode
            this.alldata.rate = data.messageContent.rate
            this.alldata.sellerId = data.messageContent.sellerId
            this.alldata.unitGuid = data.messageContent.unitGuid
            this.alldata.unitNo = data.messageContent.unitNo
            this.alldata.unitPid = data.messageContent.unitPid
            this.alldata.unitType = data.messageContent.unitType
            this.alldata.platformRate = data.messageContent.platformRate
            this.alldata.paymentChannel = data.messageContent.paymentChannel
            this.alldata.agentAccount = data.messageContent.agentAccount
            this.alldata.agentName = data.messageContent.agentName

            this.alldata.rechargeAmountMin =
              data.messageContent.rechargeAmountMin / 100
            this.alldata.rechargeAmountMax =
              data.messageContent.rechargeAmountMax / 100

            this.alldata.vxMchId = data.messageContent.vxMchId

            var str = this.alldata.paymentChannel.split(',')
            this.$set(this.alldata, 'payChannelList', [...str])

            // 水控钱包号
            this.alldata.waterWalletNo = data.messageContent.waterWalletNo
            // 电控钱包号
            this.alldata.electricWalletNo = data.messageContent.electricWalletNo

            // 平台钱包号
            this.alldata.platformWalletNo = data.messageContent.platformWalletNo
            // 电吹风钱包号
            this.alldata.hairWalletNo = data.messageContent.hairWalletNo
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    //更新支付信息
    updatagetpayrateuser() {
      console.log(this.alldata.payChannelList)
      var payChannel = ''
      for (var i = 0; i < this.alldata.payChannelList.length; i++) {
        if (this.alldata.payChannelList[i] != '') {
          payChannel += this.alldata.payChannelList[i] + ','
        }
      }
      payChannel = payChannel.replace(/^(\s|,)+|(\s|,)+$/g, '') // 去掉首尾的,

      console.log(this.alldata)
      this.$refs['alldata'].validate(valid => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl('/manager/update-unit-alipay-config'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                ...this.alldata,
                cityCode: this.alldata.cityCode,
                districtCode: this.alldata.districtCode,
                provinceCode: this.alldata.provinceCode,
                rate: this.alldata.rate,
                unitGuid: this.changeschoolid,
                unitPid: this.alldata.unitPid,
                userGuid: this.userGuid,
                unitNo: this.alldata.unitNo,
                platformRate: this.alldata.platformRate,
                paymentChannel: payChannel,
                agentAccount: this.alldata.agentAccount,
                agentName: this.alldata.agentName,
                sellerId: this.alldata.sellerId,
                authToken: this.alldata.authToken,
                rechargeAmountMin: this.alldata.rechargeAmountMin * 100,
                rechargeAmountMax: this.alldata.rechargeAmountMax * 100,
                // wxappid
                vxMchId: this.alldata.vxMchId,
                // 水控钱包号
                waterWalletNo: this.alldata.waterWalletNo,
                // 电控钱包号
                electricWalletNo: this.alldata.electricWalletNo,
                // 平台钱包号
                platformWalletNo: this.alldata.platformWalletNo,
                // 电吹风钱包号
                hairWalletNo: this.alldata.hairWalletNo
              },
              messageType: this.messageType
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                showClose: true,
                message: '配置成功',
                type: 'success'
              })
              this.getpayrateuser()
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: 'error'
              })
            }
          })
        }
      })
    },
    //分账列表新增
    fanshionable() {
      this.dataListLoading = true
      this.$http({
        url: this.$http.adornUrl('/pay/query-royalty-relation-page'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            pageNum: this.pageNum1,
            pageSize: this.pageSize1,
            searchInfo: this.changeschoolid
          },
          messageType: 0
        })
      }).then(({ data }) => {
        this.dataListLoading = false
        console.log(data)
        if (data.messageCode == 200) {
          this.fanshionabledata = data.messageContent.data
          this.recordCount1 = data.messageContent.recordCount
          this.currentPage1 = data.messageContent.pageNum
        } else {
          this.$message({
            showClose: true,
            message: data.errorMessage,
            type: 'error'
          })
        }
      })
    },
    //获取分账列表信息
    getfanshionable() {},
    onSubmit() {
      console.log(this.alldata)
      this.updatagetpayrateuser()
    },
    handleSizeChange1(val) {
      this.pageSize1 = val
      this.fanshionable()
    },
    handleCurrentChangepage1(val) {
      this.pageNum1 = val
      this.fanshionable()
    },
    addOrUpdateHandle(row) {
      console.log(row)
      this.editForm.percentage = row.percentage
      this.editForm.settleType = row.settleType
      this.editForm.settleGuid = row.settleGuid
      this.editFormVisible = true
    },
    editvisible() {
      this.editFormVisible = false
      this.$refs['editForm'].resetFields()
    },
    editataFormSubmit() {
      this.$refs['editForm'].validate(valid => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl('/pay/update-settle-account'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                percentage: this.editForm.percentage,
                settleGuid: this.editForm.settleGuid,
                settleType: this.editForm.settleType,
                unitGuid: this.changeschoolid
              },
              messageType: 0
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.editFormVisible = false
              this.fanshionable()
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: 'error'
              })
            }
          })
        }
      })
    },
    editcloseDialog(done) {
      this.$refs['editForm'].resetFields()
      done()
    },
    addfanshionable() {
      this.addFormVisible = true
    },
    addcloseDialog(done) {
      this.$refs['addForm'].resetFields()
      done()
    },
    addvisible() {
      this.addFormVisible = false
      this.$refs['addForm'].resetFields()
    },
    addataFormSubmit() {
      this.$refs['addForm'].validate(valid => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl('/pay/bind-relation'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                agentAccount: this.addForm.agentAccount,
                agentName: this.addForm.agentName,
                percentage: this.addForm.percentage,
                settleType: this.addForm.settleType,
                unitGuid: this.changeschoolid
              },
              messageType: 0
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.addFormVisible = false
              this.fanshionable()
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: 'error'
              })
            }
          })
        }
      })
    },
    deleOrUpdateHandle(row) {
      console.log(row)
      // return
      this.$confirm('此操作将解除绑定分账账户, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$http({
            url: this.$http.adornUrl('/pay/unbind-relation'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                unitGuid: row.unitGuid,
                agentAccount: row.loginName,
                agentName: row.userName,
                settleType: row.settleType,
                settleGuid: row.settleGuid
              },
              messageType: 0
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.addFormVisible = false
              this.fanshionable()
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: 'error'
              })
            }
          })
        })
        .catch(() => {})
    }
  }
}
</script>

<style lang="scss" scoped>
.el-checkbox + .el-checkbox {
  margin-left: 0;
}
.unit_payment {
  padding: 10px;
  min-width: 500px;
  .clearfix:after {
    content: '.';
    clear: both;
    height: 0;
    overflow: hidden;
    visibility: hidden;
    display: block;
  }
  .clearfix {
    zoom: 1;
  }
  .header_title {
    // padding-left: 22px;
    height: 50px;
    line-height: 50px;
    border-bottom: 1px solid #e5e9f2;
    color: #909399;
  }
  .list {
    font-size: 16px;
    font-weight: bold;
    color: #909399;
    padding-top: 20px;
    .el-form-item {
      padding-left: 22px;
      // padding-top: 5px;
      height: 50px;
      line-height: 70px;
      margin-bottom: 0px;
      width: 100%;
    }
    .el-form-item:last-child {
      border-bottom: 0px solid #e5e9f2;
    }
  }
  .fanshionable_title {
    margin-top: 20px;
    padding-left: 22px;
    height: 30px;
    color: #909399;
    border-bottom: 1px solid #e5e9f2;
  }
  .fanshionable_list {
    padding-top: 5px;
    .demo-form-inline {
      height: 40px;
    }
    // padding-left: 22px;
  }
  .page {
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>